<?php
if(PERMISSION != "F")
{
	redirectPage("index.php?module=logout");
	exit();
}
?>
<?php include('includes/header.php'); ?>

<div id="content">
          
	<div id="stage-2" style="display: block">
		<?php include('includes/header_games.php'); ?>
		<div style="clear: both">&nbsp;</div>
		<div class="title">
			<div class="t-1" style="float:left;width: 40px"><strong>No.</strong></div>
			<div class="t-1" style="float:left;width: 100px"><strong>WWID</strong></div>
			<div class="t-1" style="float:left;width: 150px"><strong>User</strong></div>
			<div class="t-1" style="float:left;width: 80px"><strong>Total Words</strong></div>
			<div class="t-1" style="float:left;width: 80px"><strong>Correct</strong></div>
			<div class="t-1" style="float:left;width: 80px"><strong>Language</strong></div>
			<div class="t-1" style="float:left;width: 110px"><strong>Time Played</strong></div>
			<div class="t-1" style="float:left;width: 180px"><strong>Played On</strong></div>
			<div style="float:left;width: 70px">&nbsp;</div>
			<div style="clear: both">&nbsp;</div>
		</div>
		
		<?php
		$sql = "SELECT games.*, users.* FROM games LEFT JOIN users ON games.user_id = users.user_id ORDER BY games.date_created DESC";
		
		$result = $db_mysql->get_array($sql);
		$No = 0;
		foreach($result as $row)
		{
			$No++;
			$id = $row["game_id"];
			$unique_id = $row["unique_id"];
			$full_name = $row["full_name"];
			$lang = strtoupper($row["crossword_lang"]);
			$word_count = $row["crossword_word_count"];
			$word_correct = $row["user_word_correct"];
			$user_time = seconds_to_time($row["user_time"]);
			$status = $row["activate"] == "1" ? "Shown" : "Hidden";
			$date_created = format_date($row["end_time"], "d/m/Y h:i:s");
		?>
		<div class="row">
			<div class="r-1" style="float:left;width: 40px"><?=$No?></div>
			<div class="r-1" style="float:left;width: 100px">&nbsp;<?=$unique_id ?></div>
			<div class="r-1" style="float:left;width: 150px">&nbsp;<?=$full_name ?></div>
			<div class="r-1" style="float:left;width: 80px"><?=$word_count ?></div>
			<div class="r-1" style="float:left;width: 80px"><?=$word_correct ?></div>
			<div class="r-1" style="float:left;width: 80px"><?=$lang ?></div>
			<div class="r-1" style="float:left;width: 110px"><?=$user_time ?></div>
			<div class="r-1" style="float:left;width: 180px"><?=$date_created?></div>
			<div class="r-detail" style="float:left;width: 70px">
				<a href="index.php?module=games_view&id=<?=$id?>">Details</a>
			</div>
			<div style="clear: both">&nbsp;</div>
		</div>
		<?php
		}
		?>
		
		
    </div>
</div>

